﻿using UnityEngine;
using UnityEngine.UI;

namespace Mars.MeshUI
{
    public class SuperText : Text
    {
        public bool transferUVMesh = true;
        
        public override Texture mainTexture
        {
            get
            {
                return base.mainTexture;
            }
        }
        
        protected override void OnPopulateMesh(VertexHelper toFill)
        {
            base.OnPopulateMesh(toFill);
            if (transferUVMesh)
            {
                UIVertex vertex = new UIVertex();
                for (int i = 0, imax = toFill.currentVertCount; i < imax; ++i)
                {
                    toFill.PopulateUIVertex(ref vertex, i);
                    vertex.uv1 = vertex.uv0;
                    vertex.uv0 = Vector2.zero;
                    toFill.SetUIVertex(vertex, i);
                }
            }
        }
    }
}